Skip to main content

Setting up DHCP client

Note: This is a basic demonstration for educational purposes. In a real network environment, DHCP servers typically serve multiple clients on a network.

  1. Install DHCP Server: First, you'll need to install a DHCP server package if it's not already installed on your Linux system.

  2. Start the DHCP Server: Before you work with client make sure your DHCP server is running. To start the DHCP server service use the following command:

    sudo systemctl start isc-dhcp-server
  3. Configure a DHCP Client: Configure a network interface to use DHCP:

    sudo nano /etc/network/interfaces

    Edit the file to look like this (assuming the interface is named "eth0"):

    auto eth0
    iface eth0 inet dhcp

    Save the file and exit the text editor.

  4. Restart the Network Service: To apply the DHCP configuration changes, restart the network service:

    sudo systemctl restart networking
  5. Monitor DHCP Server Logs: You can monitor the DHCP server logs to see lease assignments and client interactions. Use the following command to view the DHCP server logs in real-time:

    sudo tail -f /var/log/syslog | grep dhcpd
  6. Request an IP Address: You can manually trigger your Linux machine to request an IP address from the DHCP server by renewing its DHCP lease:

    sudo dhclient -r  # Release the current lease
    sudo dhclient # Request a new lease

    Check the logs to see the DHCP lease assignment.